<?php
require("dbconfig.php");
require("./class/sqlHelper.php");
require("./class/pageHelper.php");
$db = new Opmysqli(HOST, USER, PASSWORD, DBNAME);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>浏览所有商品</title>	
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body{
	font-family:微软雅黑;
	font-size:15px;
	color:#036;
	}
.color_c
{
    color:red;
    margin-top:30px;
}
img
{
	width:200px;
	height:200px;
}
li{
	width:445px;
	height:937px;
}
.btn_con
{
	margin-top:10px;
}
</style>
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<?php
//执行商品查询
if($resError = $db->msg_error())
{
	  echo "<div class=\"well color_c\">";
    echo $resError;
    echo "</div>";
    exit(0);
}

$SQL = "select * from clothes";
//clothes表中结果集的行数
$total = $db->getRowsNum($SQL);
//每页显示8条数据
$num = 8;
$page = new Page($total, $num);
$SQL = "select * from clothes order by addtime asc {$page->limit}";
$arr1 = $db->getRowsArray($SQL);
?>

<ul class="thumbnails">
<?php	foreach ($arr1 as $arr2) 
{
?>
<li class="span3">
    <div class="thumbnail">
         <a href="#" class="thumbnail"><img src="./uploads/<?php echo $arr2["pic"];?>" alt="260x180"></a>
   		 <div class="caption">
    		 <p>衣服名:<br /><span style="color:#CA3F25;"><?php echo $arr2["name"];?></span><br /><br />
        	    衣服ID:<?php echo $arr2["id"];?><br />
        	    衣服价格:<?php echo $arr2["price"];?>&yen;<br />
        	    衣服总量:<?php echo $arr2["total"];?>件</p>
        	 <?php
        	 $SQL2 = "select longth, width, sizeCode, quantity from clothes_parameter where id = {$arr2['id']}";
			 $arr3 = $db->getRowsArray($SQL2);
			 foreach ($arr3 as $arr4)
			 {
			 	echo "<p class=\"text-success\">";
			 		echo "衣服码:".$arr4["sizeCode"]."<br />长:".$arr4["longth"].
			 		     "cm&nbsp;&nbsp;&nbsp;&nbsp;宽:".$arr4["width"]."cm<br />数量:".
			 		     $arr4["quantity"]."件";
			 	echo "</p>";
			 }
			 echo "<p>衣服描述:<br />".$arr2["note"]."</p>";
			 echo "<p>添加日期:<br />".$arr2["addtime"]."</p>"
        	 ?>
         	 <p><a href="updateGoods.php?id=<?php echo $arr2['id'];?>" class="btn btn-primary">修改</a> 
            <a href="addGoodsPro.php?action=del&id=<?php echo $arr2['id'];?>&picname=<?php echo $arr2['pic'];?>" 
            onclick="return confirmDele(<?php echo $arr2['id'];?>)" class="btn btn-danger">删除</a></p>
         </div>
   </div>
</li>
<?php
}
?>
</ul>
<div class="pagination">
<?php 
echo $page->fpage(array(0, 1, 2, 3));
echo "<br />";
?>
  <ul class="pager">
<?php
echo $page->fpage(array(4, 5, 6, 7, 8));
?>
    &nbsp;&nbsp;
    <div class="input-append">
		<?php echo $page->fpage(array(9)); ?>
   </div>
  </ul>
</div>
<?php
$db->close_conn();
//解析商品信息
?>
</div>
<script src="./bootstrap/js/bootstrap.min.js"></script>
<script src="./js/jquery-1.9.1.min.js"></script>
<script src="./js/checkVali.js"></script>
<script type="text/javascript">
function confirmDele(val)
{
  return window.confirm("真的要删除id="+val+"的商品吗？");
}
</script>
</body>
</html>
    




